#include "VTime.h"

int realTime;
int virtualTime;
int timeSpeed;
int oldTimeSpeed;

void InitVirtualTime(int vTime, int tSpeed)
{
    realTime = clock();
    virtualTime = vTime;
    timeSpeed = tSpeed;
    oldTimeSpeed = 0;
}

int GetVirtualTime()
{
    int lastTime = realTime;
    realTime = clock();
    virtualTime += (realTime - lastTime) * timeSpeed;
    return virtualTime;
}

void SetTimeSpeed(int tSpeed)
{
    timeSpeed = tSpeed;
}
int GetTimeSpeed()
{
    return timeSpeed;
}
void PauseTime(bool pause)
{
    if (pause)
    {
        oldTimeSpeed = timeSpeed;
        SetTimeSpeed(0);
    }
    else
        SetTimeSpeed(oldTimeSpeed);
}
